package com.ruoyi.core.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.core.domain.custombean.ActivationCodeDetailQueryResult;
import com.ruoyi.core.vo.ActivationCodeDetailUpdateOperationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.core.mapper.ActivationCodeDetailMapper;
import com.ruoyi.core.domain.ActivationCodeDetail;
import com.ruoyi.core.service.IActivationCodeDetailService;
import org.springframework.util.Assert;

/**
 * core_detailService业务层处理
 *
 * @author ruoyi
 * @date 2020-09-28
 */
@Service
public class ActivationCodeDetailServiceImpl implements IActivationCodeDetailService {
    @Autowired
    private ActivationCodeDetailMapper activationCodeDetailMapper;

    /**
     * 查询core_detail
     *
     * @param id core_detailID
     * @return core_detail
     */
    @Override
    public ActivationCodeDetail selectActivationCodeDetailById(Long id) {
        return activationCodeDetailMapper.selectActivationCodeDetailById(id);
    }

    /**
     * 查询core_detail列表
     *
     * @param activationCodeDetail core_detail
     * @return core_detail
     */
    @Override
    public List<ActivationCodeDetail> selectActivationCodeDetailList(ActivationCodeDetail activationCodeDetail) {
        return activationCodeDetailMapper.selectActivationCodeDetailList(activationCodeDetail);
    }

    /**
     * 新增core_detail
     *
     * @param activationCodeDetail core_detail
     * @return 结果
     */
    @Override
    public int insertActivationCodeDetail(ActivationCodeDetail activationCodeDetail) {
        activationCodeDetail.setCreateTime(DateUtils.getNowDate());
        return activationCodeDetailMapper.insertActivationCodeDetail(activationCodeDetail);
    }

    /**
     * 修改core_detail
     *
     * @param activationCodeDetail core_detail
     * @return 结果
     */
    @Override
    public int updateActivationCodeDetail(ActivationCodeDetail activationCodeDetail) {
        return activationCodeDetailMapper.updateActivationCodeDetail(activationCodeDetail);
    }

    /**
     * 批量删除core_detail
     *
     * @param ids 需要删除的core_detailID
     * @return 结果
     */
    @Override
    public int deleteActivationCodeDetailByIds(Long[] ids) {
        return activationCodeDetailMapper.deleteActivationCodeDetailByIds(ids);
    }

    /**
     * 删除core_detail信息
     *
     * @param id core_detailID
     * @return 结果
     */
    @Override
    public int deleteActivationCodeDetailById(Long id) {
        return activationCodeDetailMapper.deleteActivationCodeDetailById(id);
    }

    @Override
    public List<ActivationCodeDetailQueryResult> findByBatchId(Long batchId) {
        return activationCodeDetailMapper.findByBatchId(batchId);
    }

    @Override
    public Boolean batchEdit(List<ActivationCodeDetailUpdateOperationVO> activationCodeDetails) {
        Assert.notEmpty(activationCodeDetails, "激活码更新对象不允许为空");
        activationCodeDetails.forEach(item -> {
            activationCodeDetailMapper.updateStatusById(item.getId(), item.getStatus());

        });
        return true;
    }

    @Override
    public List<ActivationCodeDetailQueryResult> findByIdSet(Long[] ids) {
        return activationCodeDetailMapper.findByIdSet(ids);
    }
}
